package com.sgb.kjwl.view.ui.adapter.pick;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.ProjectBuyEntity;
import com.sgb.kjwl.view.ui.activity.pick.PickCompanyDetailActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickProjectActivity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

@Deprecated
public class ProjectBuyAdapter extends BaseRecycleAdapter<ProjectBuyEntity> {

    private TextView priceView;

    public ProjectBuyAdapter(Context context, List<ProjectBuyEntity> datas) {
        super(context, R.layout.item_project_buy, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ProjectBuyEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        priceView = holder.getItem().findViewById(R.id.price);
        priceView.setText(entity.getPrice() + entity.getPriceUnit());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PickProjectActivity.start(context, entity.getNo());
            }
        });

        holder.itemView.findViewById(R.id.tv_company).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PickCompanyDetailActivity.start(context, entity.getCompNo());
            }
        });
    }
}
